package com.example.demo.service.impl;

import com.example.demo.dao.CategoryMapper;
import com.example.demo.pojo.Category;
import com.example.demo.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service // 注意service层的实现类上，必加这个注解
public class CategoryServiceImpl implements CategoryService {

    // 记住：Service层的实现类里调用Dao层的对象和方法
    @Autowired
    CategoryMapper categoryMapper;

    @Override
    public List<Category> getAll() {
        return categoryMapper.selectAll();
    }

    @Override
    public Category getById(Integer id) {
        return categoryMapper.selectById(id);
    }
}
